import axios from './axios'
import useAuthStore from '@/stores/authStore'

const urlPrefix = ''

// 登录接口
export const login = (param: any) => {
    return axios.post(`${urlPrefix}/api/auth/authLogin`, param)
}

// 上传图片接口
export const uploadFile = (file: any) => {
    return axios.post(`${urlPrefix}/common/upload`, file)
}


// 发送消息
export const requestMessage = (param: any) => {
    return axios.post(`${urlPrefix}/api/message/sendMessage`, param)
}

// 获取未读信息
export const noReadMessage = () => {
    return axios.get(`${urlPrefix}/api/user/noReadMessage`)
}


// 获取聊天房间列表
export const chatRoomList = () => {
    const user = useAuthStore().userInfo
    return axios.get(`${urlPrefix}/api/rooms/getAllChatRoomsByUserId?userId=${user.userId}`)
}

// 获取好友列表
export const friendsRelationShip = () => {
    const user = useAuthStore().userInfo
    return axios.get(`${urlPrefix}/api/friends/geteAllFriendsByUserId?userId=${user.userId}`)
}

// 获取所有聊天记录
export const allChatRecords = () => {
    const user = useAuthStore().userInfo
    return axios.post(`${urlPrefix}/api/message/getUserAllMessage?userId=${user.userId}`, {})
}

// 获取所有好友请求
export const allFriendsRequests = () => {
    return axios.get(`${urlPrefix}/api/friends/getAllFriendsRequests`, {})
}

// 搜索好友
export const searchUser = (userName: string) => {
    const user = useAuthStore().userInfo
    return axios.get(`${urlPrefix}/api/user/getUserByUserNameOrAccount?userName=${userName}&masterId=${user.userId}`)
}

// 添加好友
export const addFriendsUser = (data: any) => {
    return axios.post(`${urlPrefix}/api/friends/addFirends`, data)
}

// 同意好友请求
export const agreeFriendRequest = (data: any) => {
    return axios.get(`${urlPrefix}/api/friends/agreeFriendRequest?requestId=${data}`, )
}

// 获取朋友圈列表
export const getMomentList = (start: number, pos: number) => {
    return axios.get(`${urlPrefix}/api/moments/momentList?start=${start}&pos=${pos}`, {})
}
